﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GE_Database_Manager;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Text;
using System.Xml;


namespace UnitTests
{
    [TestClass]
    public class ADAPT_UnitTest1 : ADAPT
    {

        public override bool Process(GE_Database_Manager.Standardized_Wrapper wrapper)
        {
            throw new NotImplementedException();
        }

		public override string Key
		{
			get
			{
				throw new NotImplementedException();
			}
			set
			{
				throw new NotImplementedException();
			}
		}



        [TestMethod]
        public void ProccessDatabaseAttribues_test()
        {
          String path = @"C:\Users\erick\Documents\Senior Projects\UNR Data Analytics\Adapt Data\90000159 - EnelChisholmView_WTG_J001_DataAttributes.txt";
          List<string> expected = new List<string>{ "16384","Planetary Gear Box","null","g;s","90000159" };
 
          foreach (var data in proccessDataAttributes().Values.ToList())
          {
              System.Windows.Forms.MessageBox.Show(data);
          }

 
         // grab the dict as list and sort the values
            
          List<String> stringDict = this.proccessDataAttributes().Values.ToList();

         // sort both list
          stringDict.Sort();
          expected.Sort();

         Assert.AreEqual(string.Join(",", stringDict.ToArray()), String.Join(",",expected.ToArray()));   
             
        }

		[TestMethod]
		public void TestXMLReader()
		{
			// http://csharp.net-tutorials.com/xml/reading-xml-with-the-xmldocument-class/
			string path = @"C:\Users\Pat York\Documents\School\Senior Projects\UNR Data Analytics\ADRE Data\ADRESXP_100916_101013_V3.00_FullLoad\ADRESXP_100916_101013_V3.00_FullLoad\ConfigDBFile.xml";
			XmlDocument doc = new XmlDocument();
			doc.Load(path);
			foreach (XmlNode xmlNode in doc.DocumentElement.ChildNodes[0].ChildNodes[0].ChildNodes)
				MessageBox.Show(xmlNode.InnerXml);
            
		}
   
        [TestMethod]
        public void ProcessPDF_WithValidFileType_ContainingCorrectValues()
        {
            // expected serial number and location from db
            string sn = "16120935";
            string loc = "chisholm view";

            // get the actual values from both db
            Tuple<string, string> db1 = this.ProcessPDF(@"C:\Users\erick\Documents\Senior Projects\UNR Data Analytics\ADAPT\90000159 - EnelChisholmView_WTG_A001\NamePlate.pdf");

            // test for serial number and location equality in db
            Assert.AreEqual(sn, db1.Item1, true, "Serial number extracted from PDF for first ADAPT database is incorrect.");
            Assert.AreEqual(loc, db1.Item2, true, "Location extracted from PDF for first ADAPT database is incorrect.");
        }

        [TestMethod]
        public void ProcessPDF_WithValidFileType_ContainingIncorrectValues()
        {
            // expected serial number and location from db should be null
            string expectedValue = null;

            // get the actual values from db
            Tuple<string, string> db = this.ProcessPDF(@"C:\Users\avant\Documents\UNR Data Analytics\Adapt Data\90000159 - EnelChisholmView_WTG_J001_PictureOfDamage.pdf");

            // test for serial number and location equality in db
            Assert.AreEqual(expectedValue, db.Item1, true, "Serial number extracted from PDF for first ADAPT database should be NULL.");
            Assert.AreEqual(expectedValue, db.Item2, true, "Location extracted from PDF for first ADAPT database should be NULL.");
        }

        [TestMethod]
        public void ProcessPDF_WithInvalidFilePath()
        {
            // expected serial number and location from db should be null
            string expectedValue = null;

            // get the actual values from db
            Tuple<string, string> db = this.ProcessPDF(@"C:\Users\erick\Documents\Senior Projects\UNR Data Analytics\ADAPT\90000159 - EnelChisholmView_WTG_A001\");

            // test for serial number and location equality in db
            Assert.AreEqual(expectedValue, db.Item1, true, "Serial number extracted from PDF for first ADAPT database should be NULL.");
            Assert.AreEqual(expectedValue, db.Item2, true, "Location extracted from PDF for first ADAPT database should be NULL.");
        }

        [TestMethod]
        public void ProcessPDF_WithInvalidFileType()
        {
            // expected serial number and location from db should be null
            string expectedValue = null;

            // get the actual values from db
            Tuple<string, string> db = this.ProcessPDF(@"C:\Users\avant\Documents\UNR Data Analytics\Adapt Data\90000159 - EnelChisholmView_WTG_J001\Bosch Rexroth 455 60Hz Ratio=85.604.xlsm");

            // test for serial number and location equality in db
            Assert.AreEqual(expectedValue, db.Item1, true, "Serial number extracted from PDF for first ADAPT database should be NULL.");
            Assert.AreEqual(expectedValue, db.Item2, true, "Location extracted from PDF for first ADAPT database should be NULL.");
        }
    }
}
